home *** CD-ROM | disk | FTP | other *** search
/ Aminet 22 / Aminet 22 (1997)(GTI - Schatztruhe)[!][Dec 1997].iso / Aminet / dev / c / remote.lha / remote / developer / remoteconfig / main.c
C/C++ Source or Header  |  1997-10-09  |  3KB  |  132 lines

  1. /* -----------------------------------------------------------------------------
  2.  
  3.   remoteconfig - add/remove entries to application database
  4.  
  5.   10/1997 Dietmar Eilert (public domain)
  6.  
  7.   dcc main.c -// -mRR -r -proto -3.0 -l /library/dlib/remotesr.lib -o //bin/remoteconfig
  8.  
  9.   ------------------------------------------------------------------------------
  10. */
  11.  
  12. /// "includes"
  13.  
  14. #define Prototype extern
  15.  
  16. #include <stdio.h>
  17. #include <stdlib.h>
  18. #include <string.h>
  19. #include <ctype.h>
  20. #include <exec/exec.h>
  21. #include <exec/types.h>
  22. #include <dos/dos.h>
  23. #include <clib/alib_protos.h>
  24. #include <clib/dos_protos.h>
  25. #include <clib/exec_protos.h>
  26.  
  27. // remote.library includes
  28.  
  29. #include "/library/include/remote.h"
  30.  
  31. #include "/library/clib/remote_protos.h"
  32.  
  33. ///
  34. /// "prototypes"
  35.  
  36. Prototype int main(int, char **);
  37.  
  38. ///
  39. /// "globals"
  40.  
  41. char Version[] = "$VER: remoteconfig 1.0 (" __COMMODORE_DATE__ ")";
  42.  
  43. struct Library *RemoteBase;
  44.  
  45. ///
  46. /// "misc"
  47.  
  48. /* ----------------------------------- main ------------------------------------
  49.  
  50.  DOS entry point
  51.  
  52. */
  53.  
  54. int
  55. main(argc, argv)
  56.  
  57. int    argc;
  58. char **argv;
  59. {
  60.     int error = 0;
  61.  
  62.     puts("remoteconfig 10/1997 Dietmar Eilert. Public Domain.");
  63.  
  64.     if (RemoteBase = OpenLibrary("remote.library", 37)) {
  65.  
  66.         // manually initialize remote.library (we want to see the error code)
  67.  
  68.         if (error = RemoteInit()) {
  69.  
  70.             puts(RemoteError(error));
  71.         }
  72.         else {
  73.  
  74.             ULONG argArray[] = { 0, 0, 0, 0, 0 };
  75.  
  76.             struct RDArgs *rdArgs;
  77.  
  78.             // parse arguments
  79.  
  80.             if (rdArgs = ReadArgs("ADD/K,DEL/K,VALIDATE/S,FOLDER/K,DEEP/S", argArray, NULL)) {
  81.  
  82.                 if (argArray[0]) {                   // ADD/K
  83.  
  84.                     if (error = RemoteAdd((char *)argArray[0]))
  85.  
  86.                         puts(RemoteError(error));
  87.                 }
  88.  
  89.                 if (argArray[1]) {                   // DEL/K
  90.  
  91.                     if (error = RemoteRemove((char *)argArray[1]))
  92.  
  93.                         puts(RemoteError(error));
  94.                 }
  95.  
  96.                 if (argArray[2]) {                   // VALIDATE/S
  97.  
  98.                     if (argArray[4])                 // DEEP/S
  99.                         error = RemoteValidate((char *)argArray[3], REMOTE_VALIDATE_DEEP);
  100.                     else
  101.                         error = RemoteValidate((char *)argArray[3], REMOTE_VALIDATE_SMART);
  102.  
  103.                     if (error)
  104.                         puts(RemoteError(error));
  105.                     else
  106.                         puts("Validated.");
  107.                 }
  108.  
  109.                 FreeArgs(rdArgs);
  110.             }
  111.             else {
  112.  
  113.                 error = 20;
  114.  
  115.                 puts("Syntax error.");
  116.             }
  117.         }
  118.  
  119.         CloseLibrary(RemoteBase);
  120.     }
  121.     else {
  122.  
  123.         error = 20;
  124.  
  125.         puts("remote.library missing");
  126.     }
  127.  
  128.     return(error);
  129. }   
  130.  
  131. ///
  132.